package exception;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author げっしょく
 * @date 2021/7/23
 */
public class Test1 {
    public static void main(String[] args) {
        Collection<Student> list = new ArrayList<>();
        Student stu1 = new Student();
        Student student = new Student();
        student.setName("lisi");
        student.setAge(21);
        Student wangwu = new Student();
        list.add(stu1);
        list.add(student);
        list.add(wangwu);
        //迭代器
        Iterator<Student> iterator = list.iterator();
        while(iterator.hasNext()) System.out.println(iterator.next());

        System.out.println("----------------------------------");
        //增强for循环
        for (Student student1 : list) {
            System.out.println(student1);
        }
    }
}


class Student{
    private String name;
    private int age;
    private int score;
    public Student() {
    }

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getScore() {
        return score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    public void setScore(int score) {
        this.score = score;
    }
}